library(bayesm)
library(basicspace)
library(foreign)
library(car)


data <- read.dta("mode matters replication.dta")
data$mode <- data$source

BIG5 <- as.data.frame(cbind(data$Q78b_1, data$Q78b_2, data$Q78b_3, data$Q78b_4, data$Q78b_5, data$Q78b_6, data$Q78b_7, data$Q78b_8, data$Q78b_9, data$Q78b_10,data$mode))

BIG5 <- BIG5[complete.cases(BIG5),]


if(nchar(Sys.getenv("LONG_TEST")) != 0) {R=1000} else {R=1}
{
surveydat = list(k=10,x=as.matrix(BIG5[,1:10]))
Mcmc1 = list(R=R)
set.seed(66)
out=rscaleUsage(Data=surveydat,Mcmc=Mcmc1)
summary(out$mudraw)
}

a <- out$sigmadraw
a <- as.vector(a)
a <- as.data.frame(a)
results <- cbind(BIG5, a)

results$mode <- as.numeric(results$V11)
results$mode <- recode(results$mode, "1=0;2=1")

t.test(results$a~results$mode)